package com.smartticket.jeju.repository;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.smartticket.jeju.model.Ticket;

@Repository
public class TicketRepositoryImplByIbatis implements TicketRepository 
{
	@Autowired
	private SqlMapClient sqlMapClient;
	
	public List<Ticket> findAll() 
	{
		try 
		{
			return (List<Ticket>)sqlMapClient.queryForList("Ticket.selectTicket");
		} 
		catch (SQLException e) 
		{
			e.printStackTrace();
			return null;
		}
	}

	public Ticket get(int ticket_id) {
		
		Map<String, String> param = new HashMap<String, String>();
		param.put("id", "" + ticket_id);
		
		try 
		{
			return (Ticket)sqlMapClient.queryForObject("Ticket.selectTicket", param);
		} 
		catch (SQLException e) 
		{
			e.printStackTrace();
			return null;
		}
	}
	
	
}
